package com.karina.visualization.chart.model;

import com.karina.visualization.chart.model.SeriesModel.CategoryValue;

public class ValueSeriesModel extends SeriesModel<CategoryValue> {
	@Override
	protected DataModel<CategoryValue> createStepModel(
			DataModel<CategoryValue> t, double rate) {
		SeriesModel<CategoryValue> newSeriesM = (SeriesModel<CategoryValue>) super
				.createStepModel(t, rate);

		CategoryValue value = t.getValue();
		String v = value.getValue().toString();
		String cv = (getValue()).getValue().toString();
		double dv = Double.parseDouble(cv)
				+ (Double.parseDouble(v) - Double.parseDouble(cv)) * rate;
		(newSeriesM.getValue()).setValue(dv);
		return newSeriesM;
	}

	@Override
	public SeriesModel<CategoryValue> cloneMe() {
		ValueSeriesModel model = new ValueSeriesModel();

		return (SeriesModel<CategoryValue>) copy(model);
	}

	@Override
	protected DataModel<CategoryValue> copy(DataModel<CategoryValue> target) {
		SeriesModel<CategoryValue> seriesM = (SeriesModel<CategoryValue>) super
				.copy(target);
		CategoryValue value = new CategoryValue(target.getValue());
		seriesM.setValue(value);

		return seriesM;
	}
}
